package com.fc.service.impl

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.stereotype.Service;

import com.fc.entities.User;
import com.fc.service.UserDetailsService;
import com.fc.service.UserService;

/**
 * 
 * @author aacs
 *
 */
@Service("userDetailsService") 
class UserDetailsServiceImpl implements UserDetailsService {
	@Autowired private UserService userService
	
	@Override
	User getCurrentUser() {
		UserDetails user = (UserDetails)SecurityContextHolder.getContext().getAuthentication().getPrincipal()
		return userService.findByUserName(user.username)
	}
	
	@Override
	String getCurrentUserName() {
		return currentUser.userName
	}
	
	@Override
	String getCurrentUserRealName() {
		return currentUser.realName
	}
	

}